package o;

import android.app.Activity;
import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.n;
import com.huawei.appgallery.foundation.ui.css.CSSRule;
import com.huawei.appmarket.service.interactive.bean.InteractiveRecommResponse;
import java.util.ArrayList;
import java.util.List;
import o.ewm.j;

public class ebk {
    private CSSRule ʻ;
    private ebh ʼ;
    private LinearLayoutManager ʽ;
    private InteractiveRecommResponse ˊ;
    private ImageView ˋ;
    private ebj ˎ;
    private ebm ˏ;
    private int ˏॱ;
    private InteractiveRecommResponse ॱ;
    private View ॱˊ;
    private RecyclerView ॱॱ;
    private View ᐝ;

    public void ˊ(View view) {
        this.ॱˊ = view;
    }

    public void ˋ(ebh o_ebh) {
        this.ʼ = o_ebh;
    }

    public void ॱ(CSSRule cSSRule) {
        this.ʻ = cSSRule;
    }

    public void ˎ(View view) {
        if (view != null) {
            this.ॱॱ = (RecyclerView) view.findViewById(j.ͺﹳ);
            this.ˏॱ = dgm.ˎ((Activity) view.getContext());
            this.ˋ = (ImageView) view.findViewById(j.ˮॱ);
            if (this.ॱॱ != null) {
                this.ʽ = new LinearLayoutManager(view.getContext(), 0, false);
                this.ॱॱ.setLayoutManager(this.ʽ);
                if (MinimumFactory.getBoolValue(ContentManager.getInstant().getContext())) {
                    this.ॱॱ.setLayoutDirection(0);
                    this.ʽ.ˊ(true);
                }
                this.ˎ = new ebj();
                this.ॱॱ.setAdapter(this.ˎ);
                new eiy().ˏ(this.ॱॱ);
                this.ᐝ = view.findViewById(j.ͺـ);
                azb.ˊ(this.ᐝ);
                this.ˏ = new ebm(this.ʽ);
                this.ॱॱ.ॱ(new n(this) {
                    final /* synthetic */ ebk ॱ;

                    {
                        this.ॱ = r1;
                    }

                    public void ˎ(RecyclerView recyclerView, int i) {
                        if (i == 0) {
                            this.ॱ.ˏ.ˋ(this.ॱ.ʼ.ॱˉ(), this.ॱ.ˏॱ, this.ॱ.ॱॱ);
                        }
                    }

                    public void ˊ(RecyclerView recyclerView, int i, int i2) {
                    }
                });
            }
        }
    }

    public View ˏ() {
        return this.ᐝ;
    }

    public void ˊ() {
        if (this.ᐝ != null && this.ˎ != null && this.ʼ != null) {
            this.ˊ = this.ʼ.ॱ();
            this.ॱ = this.ʼ.ˎ();
            if (this.ˊ == null || !(TextUtils.isEmpty(this.ˊ.getLayoutId()) || this.ˊ.getLayoutId().equals(this.ʼ.ॱˉ()))) {
                this.ˊ = null;
                this.ʼ.ˊ(null);
                this.ʼ.ˋ(null);
            }
            ॱ(this.ʼ.ॱ());
        }
    }

    private void ॱ(final InteractiveRecommResponse interactiveRecommResponse) {
        if (ˏ(interactiveRecommResponse)) {
            this.ᐝ.setVisibility(8);
            return;
        }
        List ˊ = interactiveRecommResponse.ˊ();
        this.ᐝ.setVisibility(0);
        this.ˎ.ˎ(ˊ, interactiveRecommResponse.getLayoutId());
        this.ˎ.ˏ(this.ʻ);
        if (this.ˋ != null && (this.ʻ != null || evf.ˊ(this.ˋ))) {
            this.ˋ.setVisibility(8);
        }
        if (this.ˏ != null) {
            this.ˏ.ˋ(ˊ);
        }
        if (this.ॱˊ != null) {
            this.ॱˊ.post(new Runnable(this) {
                final /* synthetic */ ebk ˊ;

                public void run() {
                    int i = 0;
                    if (this.ˊ.ॱ == null || !this.ˊ.ॱ.equals(interactiveRecommResponse)) {
                        this.ˊ.ʼ.ˋ(interactiveRecommResponse);
                        this.ˊ.ʽ.ˏ(0);
                        Rect rect = new Rect();
                        this.ˊ.ॱˊ.getLocalVisibleRect(rect);
                        Context context = this.ˊ.ॱˊ.getContext();
                        if (context instanceof ebd) {
                            i = ((ebd) context).ˉ();
                            Rect rect2 = new Rect();
                            this.ˊ.ॱˊ.getGlobalVisibleRect(rect2, new Point());
                            if (rect.bottom == this.ˊ.ॱˊ.getHeight()) {
                                i = ((i + rect2.bottom) - epv.ॱ(context)) - epv.ॱ();
                            }
                        }
                        if (rect.bottom < this.ˊ.ॱˊ.getHeight()) {
                            i += this.ˊ.ॱˊ.getHeight() - rect.bottom;
                        }
                        if (i > 0) {
                            ebg.ॱ().ˊ(interactiveRecommResponse.ˏ(), i);
                        } else if (this.ˊ.ˏ != null) {
                            this.ˊ.ˏ.ˋ(this.ˊ.ʼ.ॱˉ(), this.ˊ.ˏॱ, this.ˊ.ॱॱ);
                        }
                    }
                }
            });
        }
    }

    private boolean ˏ(InteractiveRecommResponse interactiveRecommResponse) {
        return interactiveRecommResponse == null || CollectCheck.isEmpty(interactiveRecommResponse.ˊ()) || TextUtils.isEmpty(interactiveRecommResponse.getLayoutId()) || this.ʼ == null || !interactiveRecommResponse.getLayoutId().equals(this.ʼ.ॱˉ());
    }

    public ArrayList<String> ˋ() {
        if (this.ˏ != null) {
            return this.ˏ.ˋ(this.ॱॱ);
        }
        return null;
    }

    public InteractiveRecommResponse ˎ() {
        return this.ˊ;
    }
}
